{% extends '::base.html.twig' %}

{% block account_attributes %} class="active"{% endblock %}

{% block title %}{{ app.user }} {% trans %}Services{% endtrans %}{% endblock %}

{% block body %}
<div class="row-fluid whiteWrapper blogPage">

    <fieldset>
        <legend>{% trans %}My Services{% endtrans %}</legend>
        <hr class="smallHr">     
    </fieldset>
    {% if services | length > 0 %}
    <table class="table table-striped table-bordered">
        <thead>
            <tr>
                <th>{% trans %}Service{% endtrans %}</th>
                <th>{% trans %}Description{% endtrans %}</th>
                <th>{% trans %}Date{% endtrans %}</th>
                <th>{% trans %}Status{% endtrans %}</th>
            </tr>
        </thead>
        <tbody>
            {% for service in services %}
            <tr>
                <td>{{ service.service.getName(locale) }}</td>
                <td>{{ service.service.getDescription(locale) }}</td>
                <td>{{ service.createdAt | date('d/m/Y') }}</td>
                <td>{% if service.active == 1%}<span class="label label-warning pending">Pending</span>{% else %}<span class="label label-success completed">Completed</span>{% endif %}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
    {% else %}
    <div class="alert alert-info" style="text-align: center;">
        {% trans %}You currently don’t have any services.{% endtrans %}
    </div>
    {% endif %}
    
    <a class="btn blue right" href="{{ path('services') }}">{% trans %}Add more services{% endtrans %}</a>
    
    {% if lastPageNumber > 1 %}
    <div class="pagination pagination-centered">
        {% set paginationParameters = app.request.attributes.get('_route_params') | merge(app.request.query.all()) %}
        <ul>
            {% if page > 1 %}
            <li><a href="{{ path(app.request.attributes.get('_route'), paginationParameters | merge({'page': page-1 })) }}">&laquo;</a></li>
            {% endif %}
        {% for numberOfPage in 1..lastPageNumber %}
            {% if numberOfPage > page - 3 and numberOfPage < page + 3 %}
            <li class="{% if page == numberOfPage %}disabled{% endif %}"><a href="{{ path(app.request.attributes.get('_route'), paginationParameters | merge({'page': numberOfPage})) }}">{{ numberOfPage }}</a></li>
            {% endif %}
        {% endfor %}
        {% if page < lastPageNumber %}
            <li><a href="{{ path(app.request.attributes.get('_route'), paginationParameters | merge({'page': page+1})) }}">&raquo;</a></li>
        {% endif %}
        </ul>
    </div>
    {% endif %}
    
</div>

{% endblock %}